{include file="pageheader_erp.htm"}

<link href="styles/erp_order.css" rel="stylesheet" type="text/css" />

{insert_scripts files="../js/jquery.1.3.2.js"}
{insert_scripts files="../js/jquery.blockUI.2.23.js"}

{include file="erp_order_search.htm"}

<style type="text/css">
	.current_page_style
	{
		color:red;
		font-weight:bold;
	}
	
</style>


<script language="JavaScript">

	function view_approve_remark(order_id)
	{
		$.blockUI({  
		  message: $('#approve_remark_'+order_id), css: { 
		  top:  ($(window).height()-300) /2 + 'px', 
		  left: ($(window).width()-500) /2 + 'px'
		  }
		});	
	}
	
	$(document).ready(function(){
		
		$("img[id^='img_submit_approve_']").click(function(){
			$.unblockUI();
		});

		$("img[id^='img_close_approve_remark_']").click(function(){
			$.unblockUI();
		});		
		
	});
	
	function post_to_approve(order_id)
	{
	if(confirm('{$lang.erp_order_sure_to_post_to_approve}'))
	{
		Ajax.call('erp_order.php?act=post_to_approve', 'order_id='+order_id, postToApprove, 'POST', 'JSON');
	}
	function postToApprove(res)
	{
		if(res.error!=0)
		{
			alert(res.message);
		}
		else{
			alert(res.message);
			window.document.location="./erp_order_manage.php?act=order_list";
		}
	}
}
	
</script>

{foreach from=$order_info item=order}
{if $order.order_status eq 4 or $order.order_status eq 5 or $order.order_status eq 6 or $order.order_status eq 7}

<div class="approve_remark" id="approve_remark_{$order.order_id}">
<div class="approve_remark_head">
	<table cellpadding="0" cellspacing="0" border='0'>
		<tr>
			<td>
				<img src="./images/approve_remark.gif" />
			</td>
			<td align="right">
				<span><img style="cursor:pointer;" id="img_close_approve_remark_{$order.order_id}" src="./images/close_erp.gif" /></span>
			</td>
		</tr>
	</table>
</div>

<div class="approve_remark_box">
<table  cellpadding="5" cellspacing="0" border='0'>
	 <tr>
    	<td width="60">{$lang.erp_approve_remark}</td>	
		<td>
			<textarea rows="8" cols="55" disabled="true" id="textarea_approve_remark_{$order.order_id}">{$order.approve_remark}</textarea>
		</td>
	</tr>	
</table>
</div>
<div class="div_submit_approve">
	<img style="cursor:pointer;" id="img_submit_approve_{$order.order_id}" src="./images/submit.gif" />
</div>	
</div>

{/if}
{/foreach}


 <!-- start order list -->
 <div class="list-div" id="listDiv">
<table  cellpadding="3" cellspacing="1">
  <tr>
    <th width="5%">{$lang.erp_order_id}</th>
    <th width="8%">{$lang.erp_order_sn}</th>
 	<th>{$lang.erp_order_description}</th>
	<th width="10%">{$lang.erp_order_supplier}</th>
	<th width="8%">{$lang.erp_order_date}</th>
	<th  width="10%">{$lang.erp_order_status}</th>
	<th>{$lang.erp_operation}</th>
  <tr>
  {foreach from=$order_info item=order}
  <tr id="tr_{$order.order_id}">
    <td>{$order.order_id}</td>
	<td align="center">{$order.order_sn}</td>	
	<td>{$order.description}</td>	
	<td >{$order.supplier_name}</td>
	<td  align="center">{$order.create_date}</td>
	<td align="center">
		{if $order.order_status eq 1}{$lang.erp_order_status_inputing}{/if}
		{if $order.order_status eq 2}{$lang.erp_order_status_rating}{/if}
		{if $order.order_status eq 3}{$lang.erp_order_status_approving}{/if}
		{if $order.order_status eq 4}{$lang.erp_order_status_approve_pass}{/if}
		{if $order.order_status eq 5}<span style="color:red;">{$lang.erp_order_status_approve_reject}</span>{/if}
		{if $order.order_status eq 6}{$lang.erp_order_status_execute}{/if}
		{if $order.order_status eq 7}<span style="color:blue;">{$lang.erp_order_status_finish}</span>{/if}
	</td>
		
	<td align="center"  width="20%">
		{if $order.available_act.view eq 1}<a href="erp_order_manage.php?act=view_order&order_id={$order.order_id}">{$lang.erp_operation_view}</a>{/if}
		{if $order.available_act.edit eq 1}<a href="erp_order_manage.php?act=edit_order&order_id={$order.order_id}">{$lang.erp_operation_edit}</a>{/if}
		{if $order.available_act.delete eq 1}<a href="javascript:delete_order({$order.order_id})">{$lang.erp_operation_delete}</a>{/if}
		{if $order.available_act.post_to_rate eq 1}<a href="javascript:post_to_rate({$order.order_id})">{$lang.erp_operation_post_to_finance}</a>{/if}
		
		{if $order.available_act.rate eq 1}
			<a href="erp_order_manage.php?act=rate_order&order_id={$order.order_id}">{$lang.erp_operation_rate}</a>
			<a href="javascript:withdrawal_to_edit({$order.order_id})">{$lang.erp_operation_withdrawal}</a>
		{/if}
		
		{if $order.available_act.post_to_approve eq 1}<a href="javascript:post_to_approve({$order.order_id})">{$lang.erp_operation_post_to_approve}</a>{/if}
		{if $order.available_act.approve eq 1}
			<a href="erp_order_manage.php?act=approve_order&order_id={$order.order_id}">{$lang.erp_operation_approve}</a>
			<a href="javascript:withdrawal_to_rate({$order.order_id})">{$lang.erp_operation_withdrawal}</a>
		{/if}	
		{if $order.order_status eq 4}
			<a href="erp_order_manage.php?act=execute_order&order_id={$order.order_id}">{$lang.erp_operation_execute}</a>
		{/if}
		{if $order.order_status eq 6}
			<a href="erp_order_manage.php?act=finish_order&order_id={$order.order_id}">{$lang.erp_operation_finish}</a>
		{/if}
		{if $order.order_status eq 4 or $order.order_status eq 5 or $order.order_status eq 6 or $order.order_status eq 7}
			<a href="erp_order_manage.php?act=view_order&order_id={$order.order_id}">{$lang.erp_operation_view}</a>
			<a href="javascript:view_approve_remark({$order.order_id})">{$lang.erp_order_operation_view_approve_remark}</a>
		{/if}
		
		
		{if $order.order_status eq 4 or $order.order_status eq 6 or $order.order_status eq 7}
			<a target="_blank" href="erp_order_manage.php?act=print_order&order_id={$order.order_id}&page=1">{$lang.erp_operation_print}</a>
		{/if}
    </td>				
  </tr>
  {foreachelse}
  <tr><td class="no-records" colspan="10">{$lang.no_records}</td></tr>
  {/foreach}
   <tr><td colspan="10" align="right">{$page}</td></tr> 
</table>
</div>
<!-- end order list -->

{literal}
<script language="JavaScript">

   		function withdrawal_to_edit(order_id)
		{
			function withdrawalToEditResponse(res)
			{
				if(res.error!=0)
				{
					alert(res.message);
				}
				else{
					window.document.location="./erp_order_manage.php?act=order_list";
				}
			}
			if(confirm('{$lang.erp_order_sure_to_withdrawal_to_edit}'))
			{	
				Ajax.call('erp_order.php?act=withdrawal_to_edit', 'order_id=' + order_id, withdrawalToEditResponse, 'POST', 'JSON');
			}			
		}
		
   		function withdrawal_to_rate(order_id)
		{
			function withdrawalToRateResponse(res)
			{
				if(res.error!=0)
				{
					alert(res.message);
				}
				else{
					window.document.location="./erp_order_manage.php?act=order_list";
				}
			}
			if(confirm('{$lang.erp_order_sure_to_withdrawal_to_rate}'))
			{	
				Ajax.call('erp_order.php?act=withdrawal_to_rate', 'order_id=' + order_id, withdrawalToRateResponse, 'POST', 'JSON');
			}			
		}		
	
	
		function post_to_rate(order_id)
		{
			function postToRateResponse(res)
			{
				if(res.error!=0)
				{
					alert(res.message);
				}
				else{
					alert(res.message);
					window.document.location="./erp_order_manage.php?act=order_list";
				}
			}
			if(confirm('{$lang.erp_order_sure_to_post_order}'))
			{	
				Ajax.call('erp_order.php?act=post_to_rate', 'order_id=' + order_id, postToRateResponse, 'POST', 'JSON');
			}
		}

		function delete_order(order_id)
		{
				function deleteOrderResponse(res)
				{
					if(res.error==4)
					{
						alert(res.message);
						window.document.location="./erp_order_manage.php?act=order_list";
					}
					else if(res.error==0)
					{
						alert(res.message);
						window.document.location="./erp_order_manage.php?act=order_list";
					}
					else{
						alert(res.message);
					}
				}
				
				if(confirm('{$lang.erp_order_sure_to_delete_order}'))
				{
					Ajax.call('erp_order.php?act=delete_order', 'order_id=' + order_id, deleteOrderResponse, 'POST', 'JSON');
				}
			}
	
 
</script>
{/literal}
{include file="pagefooter.htm"}

